/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.senai.relatorio;

import br.com.senai.dao.CursoDAO;
import br.com.senai.entities.Escola;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;

/**
 *
 * @author Hugo
 */
public class GerarGrafico {

    public JFreeChart porCursoPizza(Escola escola) {

        DefaultCategoryDataset data = new DefaultCategoryDataset();

        DefaultPieDataset pieDataset = new DefaultPieDataset();
        
        for(Object[] registro: new CursoDAO().quantidadeDeLanches(escola)){
            
            
           data.setValue(Double.parseDouble(registro[1].toString()), registro[0].toString(), registro[0].toString());
            
            
        }


      JFreeChart chart = ChartFactory.createBarChart3D(null, null, "GRÁFICO", data, PlotOrientation.VERTICAL, true, true, true);
//        JFreeChart chart = ChartFactory.createPieChart(
//                "Gráfico", // Title
//                pieDataset, // Dataset
//                true, // Show legend
//                true, // Use tooltips
//                true); // Configure chart to generate URLs?

       // PiePlot plot = (PiePlot) chart.getPlot();
       // CategoryPlot plot = (CategoryPlot) chart.getCategoryPlot();
        
      //  CategorySeriesLabelGenerator gen1 = new  StandardCategorySeriesLabelGenerator("{0}: {1} ({2})");
        
//        PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator(
//                "{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%"));
//        
                
//  category.set
      
        return chart;

    }

}
